Skip to content

Refactor StitchAction and its tests to Kotlin (CATROID-1584, CATROID-1585)#5210

Open
harshsomankar123-tech wants to merge 4 commits into
Catrobat:developfrom
harshsomankar123-tech:refactor-stitch-action-kotlin
Open

Refactor StitchAction and its tests to Kotlin (CATROID-1584, CATROID-1585)#5210
harshsomankar123-tech wants to merge 4 commits into
Catrobat:developfrom
harshsomankar123-tech:refactor-stitch-action-kotlin

Conversation

@harshsomankar123-tech

@harshsomankar123-tech harshsomankar123-tech commented May 11, 2026

Copy link
Copy Markdown
Member

Related Issues

Description
This PR refactors the StitchAction class and its corresponding instrumented test StitchActionTest from Java to idiomatic Kotlin.

Key Changes

StitchAction.kt:

  • Converted core logic to idiomatic Kotlin.
  • Implemented Null Safety using safe calls (?.) and the Elvis operator (?:) to prevent NullPointerExceptions, fulfilling the requirement to eliminate !! assertions in production code.
  • Updated property access for zIndex and embroideryThreadColor.

StitchActionTest.kt:

  • Refactored the test suite to Kotlin.
  • Optimized the mock setup to use lateinit var for the embroideryPatternManagerMock, allowing for cleaner verify calls without null-check clutter or !!.
  • Corrected type handling for zIndex which is now safely handled as an Int.

General:

  • Updated copyright headers to 2026.
  • Verified that the project compiles and builds successfully.

Type of Change

  • Refactoring (non-breaking change which improves code structure/readability)

How Has This Been Tested?

  • Build Verification: Successfully ran ./gradlew assembleCatroidDebugAndroidTest to ensure all Kotlin components and test dependencies are correctly configured.
  • Static Analysis: Verified that no !! assertions are used in the core logic and that null-safety patterns are correctly applied.

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@sonarqubecloud

Copy link
Copy Markdown

@harshsomankar123-tech harshsomankar123-tech marked this pull request as ready for review May 11, 2026 19:34
@harshsomankar123-tech

Copy link
Copy Markdown
Member Author

@reichli @dorianpercic PTAL

@harshsomankar123-tech harshsomankar123-tech added the Active Member Tickets that are assigned to members that are still currently active label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Active Member Tickets that are assigned to members that are still currently active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants